<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Dem Bones: Dem::ConvexLS&lt; _Scalar &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="DemBones_small.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Dem Bones
   &#160;<span id="projectnumber">1.2.0</span>
   </div>
   <div id="projectbrief">Skinning Decomposition Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.16 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('class_dem_1_1_convex_l_s.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="class_dem_1_1_convex_l_s-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Dem::ConvexLS&lt; _Scalar &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Linear least squares solver with non-negativity constraint and optional affinity constraint.  
 <a href="class_dem_1_1_convex_l_s.html#details">More...</a></p>

<p><code>#include &quot;<a class="el" href="_convex_l_s_8h_source.html">DemBones/ConvexLS.h</a>&quot;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:ae6da3230d1826b15b369e6879cbb7191"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_dem_1_1_convex_l_s.html#ae6da3230d1826b15b369e6879cbb7191">MatrixX</a> = Eigen::Matrix&lt; _Scalar, Eigen::Dynamic, Eigen::Dynamic &gt;</td></tr>
<tr class="separator:ae6da3230d1826b15b369e6879cbb7191"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a066dff3827a4d933cfed98276e8d41d0"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_dem_1_1_convex_l_s.html#a066dff3827a4d933cfed98276e8d41d0">VectorX</a> = Eigen::Matrix&lt; _Scalar, Eigen::Dynamic, 1 &gt;</td></tr>
<tr class="separator:a066dff3827a4d933cfed98276e8d41d0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a42f2e62346ddc90f930d0d473773fd06"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_dem_1_1_convex_l_s.html#a42f2e62346ddc90f930d0d473773fd06">ConvexLS</a> (int maxSize=1)</td></tr>
<tr class="separator:a42f2e62346ddc90f930d0d473773fd06"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac601e6ddfcad0b277ad805449b3510f3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_dem_1_1_convex_l_s.html#ac601e6ddfcad0b277ad805449b3510f3">init</a> (int maxSize)</td></tr>
<tr class="separator:ac601e6ddfcad0b277ad805449b3510f3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a68f946876bc5259e699f0c311d18e266"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_dem_1_1_convex_l_s.html#a68f946876bc5259e699f0c311d18e266">solve</a> (const <a class="el" href="class_dem_1_1_convex_l_s.html#ae6da3230d1826b15b369e6879cbb7191">MatrixX</a> &amp;aTa, const <a class="el" href="class_dem_1_1_convex_l_s.html#a066dff3827a4d933cfed98276e8d41d0">VectorX</a> &amp;aTb, <a class="el" href="class_dem_1_1_convex_l_s.html#a066dff3827a4d933cfed98276e8d41d0">VectorX</a> &amp;x, bool affine, bool warmStart=false)</td></tr>
<tr class="separator:a68f946876bc5259e699f0c311d18e266"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;class _Scalar&gt;<br />
class Dem::ConvexLS&lt; _Scalar &gt;</h3>

<p>Linear least squares solver with non-negativity constraint and optional affinity constraint. </p>
<p>Solve: </p><p class="formulaDsp">
\begin{eqnarray*} min &amp;||Ax-b||^2 \\ \mbox{Subject to: } &amp; x(0).. x(n-1) \geq 0, \\ \mbox{(optional) } &amp; x(0) +.. + x(n-1) = 1 \end{eqnarray*}
</p>
<p> The solver implements active set method to handle non-negativity constraint and QR decomposition to handle affinity constraint.</p>
<p><b>_Scalar</b> is the floating-point data type. </p>

<p class="definition">Definition at line <a class="el" href="_convex_l_s_8h_source.html#l00031">31</a> of file <a class="el" href="_convex_l_s_8h_source.html">ConvexLS.h</a>.</p>
</div><h2 class="groupheader">Member Typedef Documentation</h2>
<a id="ae6da3230d1826b15b369e6879cbb7191"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae6da3230d1826b15b369e6879cbb7191">&#9670;&nbsp;</a></span>MatrixX</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class _Scalar &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">using <a class="el" href="class_dem_1_1_convex_l_s.html">Dem::ConvexLS</a>&lt; _Scalar &gt;::<a class="el" href="class_dem_1_1_convex_l_s.html#ae6da3230d1826b15b369e6879cbb7191">MatrixX</a> =  Eigen::Matrix&lt;_Scalar, Eigen::Dynamic, Eigen::Dynamic&gt;</td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="_convex_l_s_8h_source.html#l00034">34</a> of file <a class="el" href="_convex_l_s_8h_source.html">ConvexLS.h</a>.</p>

</div>
</div>
<a id="a066dff3827a4d933cfed98276e8d41d0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a066dff3827a4d933cfed98276e8d41d0">&#9670;&nbsp;</a></span>VectorX</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class _Scalar &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">using <a class="el" href="class_dem_1_1_convex_l_s.html">Dem::ConvexLS</a>&lt; _Scalar &gt;::<a class="el" href="class_dem_1_1_convex_l_s.html#a066dff3827a4d933cfed98276e8d41d0">VectorX</a> =  Eigen::Matrix&lt;_Scalar, Eigen::Dynamic, 1&gt;</td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="_convex_l_s_8h_source.html#l00035">35</a> of file <a class="el" href="_convex_l_s_8h_source.html">ConvexLS.h</a>.</p>

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a42f2e62346ddc90f930d0d473773fd06"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a42f2e62346ddc90f930d0d473773fd06">&#9670;&nbsp;</a></span>ConvexLS()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class _Scalar &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_dem_1_1_convex_l_s.html">Dem::ConvexLS</a>&lt; _Scalar &gt;::<a class="el" href="class_dem_1_1_convex_l_s.html">ConvexLS</a> </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>maxSize</em> = <code>1</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Constructor, just call <a class="el" href="class_dem_1_1_convex_l_s.html#ac601e6ddfcad0b277ad805449b3510f3">init()</a> </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">maxSize</td><td>is the maximum size of the unknown \( x \) if the affinity constraint is imposed. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="_convex_l_s_8h_source.html#l00040">40</a> of file <a class="el" href="_convex_l_s_8h_source.html">ConvexLS.h</a>.</p>
<div class="fragment"><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;                            {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        q2.resize(0);</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;        <a class="code" href="class_dem_1_1_convex_l_s.html#ac601e6ddfcad0b277ad805449b3510f3">init</a>(maxSize);</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    }</div>
</div><!-- fragment -->
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ac601e6ddfcad0b277ad805449b3510f3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac601e6ddfcad0b277ad805449b3510f3">&#9670;&nbsp;</a></span>init()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class _Scalar &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="class_dem_1_1_convex_l_s.html">Dem::ConvexLS</a>&lt; _Scalar &gt;::init </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>maxSize</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Init matrices \( Q \) in the QR decomposition used for affinity constraint </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">maxSize</td><td>is the maximum size of the unknown \( x \) if the affinity constraint is imposed. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="_convex_l_s_8h_source.html#l00048">48</a> of file <a class="el" href="_convex_l_s_8h_source.html">ConvexLS.h</a>.</p>
<div class="fragment"><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;                           {</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        <span class="keywordtype">int</span> curN=(int)q2.size()+1;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        <span class="keywordflow">if</span> (curN&lt;maxSize) {</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;            q2.resize(maxSize-1);</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="preprocessor">            #pragma omp parallel for</span></div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;            <span class="keywordflow">for</span> (<span class="keywordtype">int</span> n=curN-1; n&lt;maxSize-1; n++)</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;                q2[n]=<a class="code" href="class_dem_1_1_convex_l_s.html#ae6da3230d1826b15b369e6879cbb7191">MatrixX</a>(VectorX::Constant(n+2, _Scalar(1)).householderQr().householderQ()).rightCols(n+1);</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        }</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    }</div>
</div><!-- fragment -->
</div>
</div>
<a id="a68f946876bc5259e699f0c311d18e266"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a68f946876bc5259e699f0c311d18e266">&#9670;&nbsp;</a></span>solve()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class _Scalar &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="class_dem_1_1_convex_l_s.html">Dem::ConvexLS</a>&lt; _Scalar &gt;::solve </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="class_dem_1_1_convex_l_s.html#ae6da3230d1826b15b369e6879cbb7191">MatrixX</a> &amp;&#160;</td>
          <td class="paramname"><em>aTa</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="class_dem_1_1_convex_l_s.html#a066dff3827a4d933cfed98276e8d41d0">VectorX</a> &amp;&#160;</td>
          <td class="paramname"><em>aTb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="class_dem_1_1_convex_l_s.html#a066dff3827a4d933cfed98276e8d41d0">VectorX</a> &amp;&#160;</td>
          <td class="paramname"><em>x</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>affine</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>warmStart</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Solve the least squares problem </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">aTa</td><td>is the cross product matrix \( A^TA \) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">aTb</td><td>is the vector \( A^Tb \) </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">x</td><td>is the by-reference output and it is also the init solution (if <b>warmStart</b> == <code>true</code>) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">affine=true</td><td>will impose affinity constraint </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">warmStart=true</td><td>will initialize the solution by <b>x</b> </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="_convex_l_s_8h_source.html#l00065">65</a> of file <a class="el" href="_convex_l_s_8h_source.html">ConvexLS.h</a>.</p>
<div class="fragment"><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;                                                                                                      {</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        <span class="keywordtype">int</span> n=int(aTa.cols());</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        <span class="keywordflow">if</span> (!warmStart) x=VectorX::Constant(n, _Scalar(1)/n);</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160; </div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        Eigen::ArrayXi idx(n);</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;        <span class="keywordtype">int</span> np=0;</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;n; i++)</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;            <span class="keywordflow">if</span> (x(i)&gt;0) idx[np++]=i; <span class="keywordflow">else</span> idx[n-i+np-1]=i;</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160; </div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;        <a class="code" href="class_dem_1_1_convex_l_s.html#a066dff3827a4d933cfed98276e8d41d0">VectorX</a> p;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160; </div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> rep=0; rep&lt;n; rep++) {</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;            solveP(aTa, aTb, x, idx, np, affine, p);</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160; </div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;            <span class="keywordflow">if</span> ((<a class="code" href="namespace_dem.html#a5f2dfa58c8c80cb8b494cbdf8d82f105">indexing_vector</a>(x, idx.head(np))+<a class="code" href="namespace_dem.html#a5f2dfa58c8c80cb8b494cbdf8d82f105">indexing_vector</a>(p, idx.head(np))).minCoeff()&gt;=0) {</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;                x+=p;</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;                <span class="keywordflow">if</span> (np==n) <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;                Eigen::Index iMax;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;                (<a class="code" href="namespace_dem.html#a5f2dfa58c8c80cb8b494cbdf8d82f105">indexing_vector</a>(aTb, idx.tail(n-np))-<a class="code" href="namespace_dem.html#ae66a43a80ec99faa99e8ab163cb5beae">indexing_row</a>(aTa, idx.tail(n-np))*x).maxCoeff(&amp;iMax);</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;                std::swap(idx[iMax+np], idx[np]);</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;                np++;</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;            } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;                _Scalar alpha;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;                <span class="keywordtype">int</span> iMin=-1;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;                <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;np; i++)</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;                    <span class="keywordflow">if</span> (p(idx[i])&lt;0) {</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;                        <span class="keywordflow">if</span> ((iMin==-1)||(x(idx[i])&lt;-alpha*p(idx[i]))) {</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;                            alpha=-x(idx[i])/p(idx[i]);</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;                            iMin=i;</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;                        }</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;                    }</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;                x+=alpha*p;</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;                _Scalar eps=std::abs(x(idx[iMin]));</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;                x(idx[iMin])=0;</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;                <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;np; i++)</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;                    <span class="keywordflow">if</span> (x(idx[i])&lt;=eps) std::swap(idx[i--], idx[--np]);</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;            }</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;            <span class="keywordflow">if</span> (affine) x/=x.sum();</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        }</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    }</div>
</div><!-- fragment -->
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>include/DemBones/<a class="el" href="_convex_l_s_8h_source.html">ConvexLS.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<div class="ttc" id="anamespace_dem_html_ae66a43a80ec99faa99e8ab163cb5beae"><div class="ttname"><a href="namespace_dem.html#ae66a43a80ec99faa99e8ab163cb5beae">Dem::indexing_row</a></div><div class="ttdeci">Eigen::CwiseNullaryOp&lt; indexing_functor_row&lt; ArgType, RowIndexType &gt;, typename indexing_functor_row&lt; ArgType, RowIndexType &gt;::MatrixType &gt; indexing_row(const Eigen::MatrixBase&lt; ArgType &gt; &amp;arg, const RowIndexType &amp;row_indices)</div><div class="ttdef"><b>Definition:</b> <a href="_indexing_8h_source.html#l00081">Indexing.h:81</a></div></div>
<div class="ttc" id="aclass_dem_1_1_convex_l_s_html_ae6da3230d1826b15b369e6879cbb7191"><div class="ttname"><a href="class_dem_1_1_convex_l_s.html#ae6da3230d1826b15b369e6879cbb7191">Dem::ConvexLS::MatrixX</a></div><div class="ttdeci">Eigen::Matrix&lt; _Scalar, Eigen::Dynamic, Eigen::Dynamic &gt; MatrixX</div><div class="ttdef"><b>Definition:</b> <a href="_convex_l_s_8h_source.html#l00034">ConvexLS.h:34</a></div></div>
<div class="ttc" id="aclass_dem_1_1_convex_l_s_html_ac601e6ddfcad0b277ad805449b3510f3"><div class="ttname"><a href="class_dem_1_1_convex_l_s.html#ac601e6ddfcad0b277ad805449b3510f3">Dem::ConvexLS::init</a></div><div class="ttdeci">void init(int maxSize)</div><div class="ttdef"><b>Definition:</b> <a href="_convex_l_s_8h_source.html#l00048">ConvexLS.h:48</a></div></div>
<div class="ttc" id="anamespace_dem_html_a5f2dfa58c8c80cb8b494cbdf8d82f105"><div class="ttname"><a href="namespace_dem.html#a5f2dfa58c8c80cb8b494cbdf8d82f105">Dem::indexing_vector</a></div><div class="ttdeci">Eigen::CwiseNullaryOp&lt; indexing_functor_vector&lt; ArgType, IndexType &gt;, typename indexing_functor_vector&lt; ArgType, IndexType &gt;::VectorType &gt; indexing_vector(const Eigen::MatrixBase&lt; ArgType &gt; &amp;arg, const IndexType &amp;indices)</div><div class="ttdef"><b>Definition:</b> <a href="_indexing_8h_source.html#l00115">Indexing.h:115</a></div></div>
<div class="ttc" id="aclass_dem_1_1_convex_l_s_html_a066dff3827a4d933cfed98276e8d41d0"><div class="ttname"><a href="class_dem_1_1_convex_l_s.html#a066dff3827a4d933cfed98276e8d41d0">Dem::ConvexLS::VectorX</a></div><div class="ttdeci">Eigen::Matrix&lt; _Scalar, Eigen::Dynamic, 1 &gt; VectorX</div><div class="ttdef"><b>Definition:</b> <a href="_convex_l_s_8h_source.html#l00035">ConvexLS.h:35</a></div></div>
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="namespace_dem.html">Dem</a></li><li class="navelem"><a class="el" href="class_dem_1_1_convex_l_s.html">ConvexLS</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.16 </li>
  </ul>
</div>
</body>
</html>
